package com.supermali.entity.npc.monistor.helpful;

import com.supermali.behavior.Dxy;
import com.supermali.behavior.util.Up16Px;
import com.supermali.creater.MapCreater;
import com.supermali.creater.img.ImgHelper;
import com.supermali.creater.img.ImgKey;
import com.supermali.creater.img.ImgLoader;
import com.supermali.entity.npc.person.Person;

import java.awt.image.BufferedImage;

/**
 * @project runner
 * @Date 2021/3/4
 * @Auth yangrui
 **/
public class BulletFlower extends HelpfulAbstract {
    // 上移16px
    Up16Px up16Px;

    public BulletFlower(Double x, Double y, MapCreater mapCreater) {
        super(x, y, mapCreater);
    }

    @Override
    public void helpPerson() {
        Person person = getMapCreater().getPerson();
        if(person.getBigStatus()== Person.BigStatus.SMALL){
            person.setBigStatus(Person.BigStatus.BIG);
        }else person.setBigStatus(Person.BigStatus.BIG_BULLET);
    }

    @Override
    public void proccessData(long delta) {
        if(!up16Px.isOver()){
            Dxy dxy = up16Px.up(delta);
            this.setY(getY()+dxy.getDy());
        }
    }

    @Override
    public void init() {
        ImgHelper imgHelper = ImgLoader.getImgHelper(ImgKey.Monistor.BULLET_FLOWER);
        BufferedImage select = imgHelper.select(0);
        this.setBufferedImage(select);
        up16Px = new Up16Px();
        up16Px.up(0);
    }
}
